/**
 * 
 */
package it.unitn.testbed.server.serial;

/**
 * Descriptor of a field inside of a serial message.
 * 
 * Each field has:
 * <ul>
 * <li>a type ({@link FieldType#type})
 * <li>a name ({@link FieldType#name})
 * <li>a length bigger than 1 for array field, 1 for non-array field (
 * {@link #length}).
 * 
 * @author Stefan Guna
 * 
 */
public class FieldType {
	private int length;

	private String name;

	private Class<?> type;

	/**
	 * @param type
	 * @param name
	 * @param length
	 */
	public FieldType(Class<?> type, String name, int length) {
		this.type = type;
		this.name = name;
		this.length = length;
	}

	/**
	 * @return the length
	 */
	public int getLength() {
		return length;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the type
	 */
	public Class<?> getType() {
		return type;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return type.getName() + " " + name + "[" + length + "]";
	}

}
